﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Autocomplete.Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Auto complete</title>
    <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>

    <script type="text/javascript">
        $(document).ready(function () {
            /*
            PageMethods.GetCountryInfo("denmark", function (res) {
            //sucess
            //alert(res);
            $("#result").append("<div class='nbr'>" + res.name + "</div>");
            }, function () {
            //fail
            $("#result").append("<div class='nbr'>failed to get a random number...</div>");
            clearInterval(timer);
            });
            */
            $("#searchinput").change(function () {

                PageMethods.GetSeachResults("ca", function (res) {
                    //sucess
                    for (o in res) {
                        $("#result").append("<div class='nbr'>" + res[o] + "</div>");
                    }

                }, function (response) {
                    //fail
                    //$("#result").append("<div class='nbr'>failed:" + response.Message + "</div>");

                    for (o in response) {
                        $("#result").append("<div class='nbr'>" + response[o] + "</div>");
                    }
                    //clearInterval(timer);
                });
            });
        });
    </script>
</head>
<body>
    <div id="wrapper">
        <form id="form1" runat="server">
    <asp:ScriptManager ID="uiScriptManager" runat="server" EnablePageMethods="true">
    </asp:ScriptManager>

        <div id="search">
        <input type="text" name="searchinput" id="searchinput" />
        </div>
        <div id="result"></div>
        </form>
    </div>
</body>
</html>
